import { defineStore } from 'pinia'

export const useTheme = defineStore('theme', {
  state: () => ({
    isNightMode: false
  }),
  actions: {
    toggleTheme() {
      this.isNightMode = !this.isNightMode
      localStorage.setItem('theme', this.isNightMode ? 'night' : 'day')
    },
    initTheme() {
      const savedTheme = localStorage.getItem('theme')
      this.isNightMode = savedTheme === 'night'
    }
  }
})
